package cn.gson.crmdemo.controller.finance;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import cn.gson.crmdemo.model.service.ReturneService;
import cn.gson.crmdemo.model.service.ThService;

@Controller
public class ReturneController {
	@Autowired
	ReturneService rs;
	@Autowired
	ThService Te;
	//查询退货单
	public Map<String,Object> yy(JSONArray selectfkfp,Page page) {
		Map<String, Object> map=new HashMap<String,Object>();
		map.put("list",selectfkfp);
		map.put("total",page.getTotal());
		return map;
	}
		@RequestMapping("thdjl")
		@ResponseBody
		public Map<String,Object>fkfp(Integer pageNum,Integer pasgeSize,String rTitle,Integer rState){
			//分页
			Page<Object> page = PageHelper.startPage(pageNum,pasgeSize);
			//查询数据
			JSONArray selectfkfp=rs.selectthd(rTitle,rState);
			//创建Map集合
			return this.yy(selectfkfp, page);
		}
		@RequestMapping("tdxgzt")
		public String xgzt(int a,int r,int o) {
			rs.xgzt(a, r,o);
			return "redirect:thdjl?pageNum=1&pasgeSize=7";
		}
		/*
		 * 退货模糊查询
		 */
		@RequestMapping("th-mhcxzt")
		@ResponseBody
		public Map<String,Object>selectZt(Integer pageNum,Integer pasgeSize,String zt){
			//分页
			Page<Object> page = PageHelper.startPage(pageNum,pasgeSize);
			//查询数据
			JSONArray selectfkfp=Te.selectZt("%"+zt+"%");
			//创建Map集合
			return this.yy(selectfkfp, page);
		}
		
		//查询是否退款
		@RequestMapping("th-sftk")
		@ResponseBody
		public Map<String,Object>selecttk(Integer pageNum,Integer pasgeSize,Integer y){
			//分页
			Page<Object> page = PageHelper.startPage(pageNum,pasgeSize);
			//查询数据
			JSONArray selectfkfp=Te.selecttk(y);
			//创建Map集合
			return this.yy(selectfkfp, page);
		}
		
}
